
var rules=[];
function ckeck(ckeckFunc,index){
	return ckeckFunc(this[index]);
}
function compare(x, y){//比较函数
	return x.checks.length-y.checks.length;
}
export function overload(checks,func,target){
	if(target){
		rules.push({
			'checks':checks,
			'func':func,
			'target':target
		});
		rules.sort(compare);
	}else{
		var args=checks;
		var thisVal=func;
		var i=rules.length;
		while(i--){
			var rule=rules[i];
			if(args.callee===rule.func){
				if(rule.checks.length>=args.length){
					if(rule.checks.every(ckeck,args)){
						return rule.target.apply(thisVal,args);
					}
				}
			}
		}
		return this;
	}
};